package com.lntea.redis;

import java.util.List;

import org.junit.Before;
import org.junit.Test;

import redis.clients.jedis.Jedis;
import redis.clients.jedis.Transaction;

public class TransactionDemo {
	Jedis jedis;
	Transaction transaction;
	
	@Before
	public void connect(){
		jedis = new Jedis("192.168.1.108", 6379);
	}
	
	@Test
	public void multi(){
		transaction = jedis.multi();
	}
	
	@Test
	public void exec(){
		List<Object> list = transaction.exec();
		System.out.println(list.toString());
	}
	
	@Test
	public void discard(){
		String result = transaction.discard();
		System.out.println("discard result: "+result);
	}
	
	@Test
	public void watch(){
		String result = jedis.watch("t1");
		System.out.println("watch result: "+result);
	}
	
	@Test
	public void unwatch(){
		String result = jedis.unwatch();
		System.out.println("unwatch result: "+result );
	}
}
